package com.example.tweenanimation;
        import androidx.appcompat.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;
        import android.view.animation.Animation;
        import android.view.animation.AnimationUtils;
        import android.widget.Button;
        import android.widget.ImageView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button btnOne,btnTwo,btnThree,btnFour;
    private ImageView ivBean;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnOne=(Button) findViewById(R.id.btn_one);
        btnTwo=(Button) findViewById(R.id.btn_two);
        btnThree=(Button) findViewById(R.id.btn_three);
        btnFour=(Button) findViewById(R.id.btn_four);
        btnOne.setOnClickListener(this);
        btnTwo.setOnClickListener(this);
        btnThree.setOnClickListener(this);
        btnFour.setOnClickListener(this);
        ivBean=(ImageView) findViewById(R.id.iv_bean);
    }

    @Override
    public void onClick(View view) {
        switch(view.getId()){
            case R.id.btn_one:      //渐变
                Animation alpha= AnimationUtils.loadAnimation(this,R.anim.alpha_animation);
                ivBean.startAnimation(alpha);
                break;
            case R.id.btn_two:      //旋转
                Animation rotate= AnimationUtils.loadAnimation(this,R.anim.rotate_animation);
                ivBean.startAnimation(rotate);
                break;
            case R.id.btn_three:    //缩放
                Animation scale= AnimationUtils.loadAnimation(this,R.anim.scale_animation);
                ivBean.startAnimation(scale);
                break;
            case R.id.btn_four:     //平移
                Animation translate= AnimationUtils.loadAnimation(this,
                        R.anim.translate_animation);
                ivBean.startAnimation(translate);
                break;
        }
    }
}
